package org.example.mapper;


import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.pojo.Mushroom;
import org.example.pojo.MapData;
import org.example.pojo.ScatterData;

import java.util.List;


@Mapper
public interface MushroomMapper {


    @Select("SELECT\n" +
            "    location,\n" +
            "    SUM(CASE WHEN name = '有毒的' THEN 1 ELSE 0 END) AS count1,\n" +
            "    SUM(CASE WHEN name = '可食用' THEN 1 ELSE 0 END) AS count2,\n" +
            "    SUM(CASE WHEN name = '不可食用' THEN 1 ELSE 0 END) AS count3,\n" +
            "    SUM(CASE WHEN name IN ('有毒的', '可食用', '不可食用') THEN 1 ELSE 0 END) AS count4\n" +
            "FROM\n" +
            "    mushroom.mushroom\n" +
            "GROUP BY\n" +
            "    location;")
    List<MapData> selectMapDataList();


    @Select("select * from mushroom.mushroom where name = #{type}")
    List<Mushroom> selectCategoryListByType(String type);

    @Select("select DATE(timestamp ) as date,count(*) as count from mushroom.mushroom where name = #{type} group by DATE(timestamp ) order by date")
    List<ScatterData> selectScatterDataListByType(String type);

}
